<?php
require_once('../config/auth.php');
require_once('information.cl.php');
$__CURRENT_PAGE__ = 'infos';
$__TITLE__ ="Formulaire d'ajouter une information";
$information = new Information();
$message = '';
if(count($_POST) > 0 ) {

  $informationData = $information->save($_POST);
    if(!$information->hasError()) {
        $message = "<div class='alert alert-success'>information sauvegardés avec succès</div>";
    }
}
elseif(!empty($_GET['id'])) {
    $information->loadInformationById($_GET['id']);
}
 require_once(dirname(__FILE__).'/../config/head.php');
?>
<body>
<?php require_once(dirname(__FILE__).'/../config/menu.php'); ?>
<div class="container">
 <h1>Ajouter une information</h1>
 <?php echo $message ?>
 <form method="post">
 	<input type="hidden" name="id" value="<?php echo $information->getId() ?>" />
  <div class="row"> 
    <div class="span4">
      <label>Titre:</label>
      <input type="text" name="title"  id="title"  size="50" maxlength="50" class="input-xxlarge" value="<?php echo $information->getTitle() ?>">
      <?php echo $information->getError('title') ?>
    </div> 
  </div> 
   
  <div class="row">   
    <div class="span4">
      <label>Texte:</label>
      <textarea id="txt" name="txt" rows="10"><?php echo $information->getTxt() ?></textarea>
      <?php echo $information->getError('txt') ?> 
    </div>
  </div>
  
  <div class="row">
     <div class="span2">
         <input type="reset" value="Annuler" class="btn btn-large btn-block">
     </div>
     <div class="span2 offset3">
         <input type="submit" value="Valider" class="btn btn-success btn-large btn-block">
     </div>
 </div>  
 </form>
</div>
</body>
